﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace syc.ZhiJian
{
    public partial class 接箍质保书 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                
                //取出第一个DATA
                DataView dv = (DataView)this.SqlDataSource1.Select(new DataSourceSelectArguments());
                data.Value = dv[0][1].ToString();
                tof.DataBind();
                if (tof.SelectedValue == "True")stamp.Visible = true;
                if (tof.SelectedValue == "False")stamp.Visible = false;
                //厂家名称
                DropDownList1.DataBind();
                Label1.Text = DropDownList1.SelectedValue;

            }
            tof.DataBind();
            if (tof.SelectedValue == "True") stamp.Visible = true;
            if (tof.SelectedValue == "False") stamp.Visible = false;

        }

        protected void Button_Save_Click(object sender, EventArgs e)
        {
            //更新数据库
            SqlDataSource1.Update();
        }

        //盖去章
        protected void Sign_Click(object sender, EventArgs e)
        {
            String id = Request.QueryString["ID"];
            tof.DataBind();
            if (tof.SelectedValue == "True")
            {
                //反向的操作，记住，如果之前为合格，则变成待检
                SqlDataSource1.UpdateCommand = "UPDATE [原料到货记录] SET [质检结果]=0,[状态]=1 WHERE ID=" + id;
            }
            else
            {
                //如果为待检，则为合格
                SqlDataSource1.UpdateCommand = "UPDATE [原料到货记录] SET [质检结果]=1,[状态]=2 WHERE ID=" + id;
            }
            //更新数据库
            SqlDataSource1.Update();
            tof.DataBind();
            if (tof.SelectedValue == "True") stamp.Visible = true;
            if (tof.SelectedValue == "False") stamp.Visible = false;
        }
    }
}
